package com.itheima.health.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.health.entity.CheckGroup;
import com.itheima.health.mapper.CheckGroupMapper;
import com.itheima.health.service.CheckGroupService;
import org.springframework.stereotype.Service;

@Service
public class CheckGroupServiceImpl extends ServiceImpl<CheckGroupMapper, CheckGroup> implements CheckGroupService {
    @Override
    public Page getByPage(Integer page, Integer pageSize, String code) {
        Page<CheckGroup> groupPage = new Page<>(page,pageSize);
        LambdaQueryWrapper<CheckGroup> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(code != null,CheckGroup::getCode,code).or().eq(code != null,CheckGroup::getHelpCode,code)
                    .or().eq(code != null,CheckGroup::getName,code);

        this.page(groupPage,queryWrapper);
        return groupPage;
    }
}
